<?php

class HPages {
	function getPageIdByAlias($alias) {
		$a = HSql::fetch2Array(HSql::doQuery("SELECT id, page_alias FROM portal_pages WHERE page_alias = '$alias' AND portal_id = '".PORTAL_ID."'"));			
		if (count($a) != 0)
			return $a[0]['id'];		
		else {
			$a = HSql::fetch2Array(HSql::doQuery("SELECT id, page_alias FROM portal_pages WHERE page_alias = 'Home' AND portal_id = '".PORTAL_ID."'"));	
			return $a[0]['id'];
		}
	}
	
	function getModulesByPane($page_id, $panename) {
		$a = HSql::fetch2Array(HSql::doQuery("SELECT * FROM portal_pages_modules WHERE page_id = '$page_id' AND pane_name = '$panename' ORDER BY position DESC"));
		return $a;
	}
	
	function getLayoutByPageAlias($alias) {
		$a = HSql::fetch2Array(HSql::doQuery("SELECT page_alias, layout_name FROM portal_pages WHERE page_alias = '$alias' AND portal_id = '".PORTAL_ID."'"));					
		if (count($a) != 0)
			return $a[0]['layout_name'];		
		else
			return 'default';
	}
}